﻿/*function $(element) {
  if (typeof element == 'string')
    element = document.getElementById(element);
  return element;
} */

var XMLHttp = {
_createXMLHttpRequest : function()
     {     
         if (window.XMLHttpRequest)
         {
             var objXMLHttp = new XMLHttpRequest();

         }
         else
         {                      
             var MSXML = ['MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
             var Count = MSXML.length;
             for(var i = 0; i < Count; i ++)
             {
                 try
                 {
                     var objXMLHttp = new ActiveXObject(MSXML[i]);        
                     break;
                 }
                 catch(e)
                 {
                 }
             }
          }          
        
         // mozilla某些版本没有readyState属性

         if (objXMLHttp.readyState == null)
         {
             objXMLHttp.readyState = 0;

             objXMLHttp.addEventListener("load", function ()
                 {
                     objXMLHttp.readyState = 4;
                    
                     if (typeof objXMLHttp.onreadystatechange == "function")
                     {
                         objXMLHttp.onreadystatechange();
                     }
                 },   false);
         }

         return objXMLHttp;
     },
    
    
   //method 传递方式(GET,POST)
   //url http字符串包括查询字符串
   //data 发送的数据 没有就传 null或''
   //sendtype 请求方式(true 异步 false 同步)
   //callback 回调函数
   //datatype 编码方式(xml "text/xml",普通 "application/x-www-form-urlencoded; charset=UTF-8"或"application/x-www-form-urlencoded; charset=GB2312")
_sendRequest : function(method, url, data, sendtype, datatype, callback)
     {
         var objXMLHttp = this._createXMLHttpRequest();
        
         with(objXMLHttp)
         {
             try
             {
                 // 加随机数防止缓存
                 if (url.indexOf("?") > 0)
                 {
                     url += "&randnum=" + Math.random();
                 }
                 else
                 {
                     url += "?randnum=" + Math.random();
                 }
                
                 open(method, url, sendtype);                                    
                 setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=gb2312");                                                        
                 send(data);
                 onreadystatechange = function ()
                 {                  
                     if (objXMLHttp.readyState == 4 && (objXMLHttp.status == 200 || objXMLHttp.status == 304))
                     {
                         if(callback != null)
                         {
                             callback(objXMLHttp);
                         }
                         else
                         {
                           return objXMLHttp.responseText;
                         }
                     }
                 }
                
               
             }
             catch(e)
             {
                 alert(e+"/n"+'你的浏览器版本太低,建议你升级浏览器');
             }
         }
     }
    
    
}



// JScript File 翻页JS方法
function submitInput( evt)
{	
	evt = (evt) ? evt : (window.event) ? event : null;
	if ( evt.keyCode==13){
		
		return true;
	}
		return false;
	
}
/*function renderSelect( originalRequest)
{
    var tex = originalRequest.responseText;	       
    if(tex == "") return;
 
  
    reInnerHTML($("orderList"), tex);
    if($("messageZone") != null)
    {
        $("messageZone").style.display = "none";
    }
    scroll(0,0);
}*/

var payData;

var reInnerHTML = function(ele,innerHtml) {
			var nA=navigator.appVersion;
			if(nA.indexOf('MSIE')>=0)var curIE=nA.substr(nA.indexOf('MSIE')+5,3);
			if (curIE){
				//innerHtml=innerHtml.replace(/<script([^>]*)>/gi,"<script$1 defer=\"true\">");
				var reStartScript=/^(\s*<script)/gi;
				if (reStartScript.test(innerHtml)){
					innerHtml="<span style=\"display:none;\">Hack IE</span>"+innerHtml;
					ele.innerHTML=innerHtml;
					ele.removeChild(ele.firstChild);
					if(ele.firstChild.tagName.toUpperCase()=="SCRIPT")
					{
					    var strScriptHtml = ele.firstChild.innerHTML.replace(/^\s*var\s*payData\s*\=/gi,"payData =");
					    eval(strScriptHtml);
					}
				}else{
					ele.innerHTML=innerHtml;
				}

			}else{
				var newObj=document.createElement(ele.tagName);
				newObj.id=ele.id;
				newObj.className=ele.className;
				newObj.innerHTML = innerHtml;
				ele.parentNode.replaceChild(newObj,ele);
			}
		}
		

var outputDataUrl = "./outputData.aspx";
var loading_string = "<span class=\"your_news\"><img alt=\"load\" src=\"images/loading.gif\" align=\"middle\"  bold=\"0\"  /> 正在加载...</span>";

String.prototype.Trim = function(){ return this.replace(/(^\s+)|\s+$/g,""); }

//回调数据
function loadData(orderType,Id)
{
  
    if(jQuery("#messageZone").get(0) != null)
    {
        jQuery("#messageZone").get(0).style.display = "none";
        var s_top = document.documentElement.scrollTop + 10;
        if(s_top < 90) s_top = 90;
       jQuery("#messageZone").get(0).style.top = s_top + "px";
    }
    
    //var parsStr = "?Dtype="+ orderType + "&Id=" + Id  + "&d="  + new Date();    
    //var myurl = outputDataUrl + parsStr ;
    
    var myurl = outputDataUrl;
         		    
    var pars = "";	  
    
    //var aAjax = XMLHttp._sendRequest('GET', myurl, '', true, "text/xml", renderSelect)
    
     //jquery ajax
     var searchType;
    serrchType = getSearchType(orderType);
    // jQuery.get(myurl,{Dtype:orderType,Id:Id,d:new Date()},
     jQuery.get(myurl,{Dtype:orderType,Id:Id,SerrchType:serrchType,d:new Date()}, 
     function(data)
                {
                    var tex = data;	       
                    if(tex == "") return;                    
                    if(jQuery('.phone_pop'))
                        jQuery('.phone_pop').remove();
                        
                         
                    //保存select的选中状态。
                    var l_type = jQuery("#l_type").find("option:selected").val();
                    var o_status = jQuery("#o_status").find("option:selected").val();
                    var l_status = jQuery("#l_status").find("option:selected").val();
                    
                    
                    reInnerHTML(jQuery("#orderList").get(0), tex);
                    
                    jQuery("#l_type").val(l_type);
                    jQuery("#o_status").val(o_status);
                    jQuery("#l_status").val(l_status);
                    
                    if(orderType.toLowerCase()!="order")
                    {
                        jQuery('.phone_pop').remove();
                    }
                    
                    if(jQuery("#messageZone").get(0) != null)
                    {
                        jQuery("#messageZone").get(0).style.display = "none";
                    }
                    scroll(0,0);
                }
     );
     
     
     //
     
       	  
   // var myAjax = new  Ajax.Request(myurl,{method: 'get', parameters: pars, onComplete: renderSelect});
}

function getSearchType(orderType)
{
    var searchStr;
    if(orderType=="searchlotteryorder")
    {
        var l_type = -1;
        if(jQuery("#l_type"))
           l_type = jQuery("#l_type").find("option:selected").val();
        var o_status = -1;
        if(jQuery("#o_status"))
           o_status = jQuery("#o_status").find("option:selected").val(); 
        var l_status = -2;
        if(jQuery("#l_status"))
           l_status = jQuery("#l_status").find("option:selected").val();
        searchStr = l_type + "|" + o_status + "|" + l_status;
    }
    else if (orderType=="mobileorder")
    {
        
        searchStr = "3|1|3";
    }
    return searchStr;
}

/////add by ztx 2012-7-26 
//function loadSearchData(orderType,Id)
//{
////alert(orderType);
//    if(jQuery("#messageZone").get(0) != null)
//    {
//        jQuery("#messageZone").get(0).style.display = "none";
//        var s_top = document.documentElement.scrollTop + 10;
//        if(s_top < 90) s_top = 90;
//       jQuery("#messageZone").get(0).style.top = s_top + "px";
//    }
//    
//    var myurl = outputDataUrl;
//         		    
//    var pars = "";	  
//    
//    var searchType;
//    serrchType = getSearchType(orderType);
//     
//     //jQuery.get(myurl,{Dtype:orderType,Id:Id,LT:l_type,OS:o_status,LS:l_status,d:new Date()},
//    jQuery.get(myurl,{Dtype:orderType,Id:Id,SerrchType:serrchType,d:new Date()}, 
//     function(data)
//                {
//                    
//                    var tex = data;	       
//                    if(tex == "") return;                    
//                    if(jQuery('.phone_pop'))
//                    jQuery('.phone_pop').remove();
//                    
//                    //保存select的选中状态。
//                    var l_type = jQuery("#l_type").find("option:selected").val();
//                    var o_status = jQuery("#o_status").find("option:selected").val();
//                    var selsct1 = jQuery("#l_status").find("option:selected").val();
//                    
//                    reInnerHTML(jQuery("#orderList").get(0), tex);
//                    
//                    jQuery("#l_type").val(l_type);
//                    jQuery("#o_status").val(o_status);
//                    jQuery("#l_status").val(l_status);
//                    
//                    //处理select
//                    
//                    
//                    if(orderType.toLowerCase()!="order")
//                    {
//                        jQuery('.phone_pop').remove();
//                    }
//                    
//                    if(jQuery("#messageZone").get(0) != null)
//                    {
//                        jQuery("#messageZone").get(0).style.display = "none";
//                    }
//                    scroll(0,0);
//                }
//     ); 
//     }

///kkk

function loadData_forsucceedorder(orderType,Id,modify)
{
        if(jQuery("#messageZone").get(0) != null)
            {
                jQuery("#messageZone").get(0).style.display = "none";
                var s_top = document.documentElement.scrollTop + 10;
                if(s_top < 90) s_top = 90;
               jQuery("#messageZone").get(0).style.top = s_top + "px";
            }
            
            //var parsStr = "?Dtype="+ orderType + "&Id=" + Id  + "&d="  + new Date();    
            //var myurl = outputDataUrl + parsStr ;
            
            var myurl = outputDataUrl;;
            
            if(modify=="true")
            {
               var pars = "";	  
            
           
             
             jQuery.get(myurl,{modify:"true",Dtype:orderType,Id:Id,d:new Date()},
             function(data)
                    {
                        var tex = data;	       
                        if(tex == "") return;                    
                      
                        reInnerHTML(jQuery("#orderList").get(0), tex);
                        
                        if(jQuery("#messageZone").get(0) != null)
                        {
                            jQuery("#messageZone").get(0).style.display = "none";
                        }
                        scroll(0,0);
                    }
             );
              
            }
            else
            {
               var pars = "";	  
            
           
             
             jQuery.get(myurl,{Dtype:orderType,Id:Id,d:new Date()},
             function(data)
                        {
                            var tex = data;	       
                            if(tex == "") return;                    
                          
                            reInnerHTML(jQuery("#orderList").get(0), tex);
                            
                            if(orderType.toLowerCase()=="order")
                            {
                                float_phone_pop_display();
                            }
                            
                            if(jQuery("#messageZone").get(0) != null)
                            {
                                jQuery("#messageZone").get(0).style.display = "none";
                            }
                            scroll(0,0);
                        }
             );
           
            }
            
           
                 		    
           
             
             
             //
             
               	  
           // var myAjax = new  Ajax.Request(myurl,{method: 'get', parameters: pars, onComplete: renderSelect});

}
///kkk
  		
function clickDetails()
{
    //$("details").hide();
    
    jQuery("#details").get(0).hide();
    
    //$("orderList").innerHTML =  "<span class='your_news'><img alt='load' src='images/loading.gif' align='absMiddle'  bold='0'  /> 正在加载...</span>";
    
    jQuery("#orderList").html("<span class='your_news'><img alt='load' src='images/loading.gif' align='absMiddle'  bold='0'  /> 正在加载...</span>");

    loadData("balance","0|1|0");

}


function sortQuestion(obj,pageindex)
{
    var selectobj = obj.options[obj.selectedIndex];
   // selectobj.selected =true;
    var value = selectobj.value;
    var index = "0|" + pageindex + "|" + value;
    loadData("question",index);
}